<?php
// 游戏/软件数据 - 扩展的详细信息
$game = [
    'id' => 101,
    'title' => '星际探险家：未知边界',
    'subtitle' => '开启一段跨越星系的冒险之旅',
    'description' => '《星际探险家：未知边界》是一款开放世界科幻冒险游戏，玩家将扮演一名星际探险家，在浩瀚的宇宙中探索未知星球，收集资源，建造基地，与外星文明接触，并揭开宇宙深处的神秘面纱。',
    'cover_image' => 'https://picsum.photos/seed/gamestar1/1600/900',
    'screenshots' => [
        'https://picsum.photos/seed/gamestar2/1600/900',
        'https://picsum.photos/seed/gamestar3/1600/900',
        'https://picsum.photos/seed/gamestar4/1600/900',
        'https://picsum.photos/seed/gamestar5/1600/900'
    ],
    'trailer_url' => '#',
    'category' => '开放世界',
    'tags' => ['科幻', '冒险', '探索', '建造', '多人游戏'],
    'release_date' => '2023-10-15',
    'developer' => '银河游戏工作室',
    'publisher' => '星际娱乐',
    'platforms' => ['PC', 'PlayStation 5', 'Xbox Series X/S', 'Switch'],
    'price' => '¥198',
    'discount' => '10%',
    'discounted_price' => '¥178',
    'rating' => 4.8,
    'rating_count' => 2356,
    'features' => [
        '探索超过100个独特的星球，每个星球都有其特有的生态系统和资源',
        '建造和升级你的太空站和地面基地，招募船员，管理资源',
        '与数十种独特的外星生物互动，有些友好，有些充满敌意',
        '参与史诗般的太空战斗，升级你的飞船武器和防御系统',
        '揭开宇宙中古老文明的秘密，解开星系形成的谜团',
        '支持4人合作模式，与好友一起探索宇宙的奥秘'
    ],
    'storyline' => '在2145年，人类首次成功研发了超光速引擎，开启了星际探索的新纪元。作为一名新晋的星际探险家，你将驾驶自己的飞船"先锋号"，穿越虫洞，探索银河系边缘的未知区域。在那里，你发现了一个古老的外星文明遗迹，其中隐藏着足以改变人类命运的科技和秘密。同时，一股神秘的力量正在银河系中崛起，威胁着所有智慧生命的存在。你的选择将决定宇宙的未来。',
    'gameplay' => [
        '开放世界探索：自由探索广阔的宇宙，没有线性任务限制',
        '资源采集与建造：收集各种资源，建造自己的基地和飞船',
        '角色扮演：通过选择和行动塑造你的角色和船员的命运',
        '实时战斗：参与太空和地面战斗，使用各种武器和战术',
        '交易系统：在不同星系间进行贸易，获取稀有资源',
        '科技树：解锁新的科技和装备，提升你的探索能力'
    ],
    'system_requirements' => [
        'minimum' => [
            'os' => 'Windows 10 64-bit',
            'processor' => 'Intel Core i5-8400 / AMD Ryzen 5 2600',
            'memory' => '8 GB RAM',
            'graphics' => 'NVIDIA GTX 1060 6GB / AMD RX 580 8GB',
            'storage' => '60 GB 可用空间',
            'directx' => 'Version 12'
        ],
        'recommended' => [
            'os' => 'Windows 10/11 64-bit',
            'processor' => 'Intel Core i7-10700K / AMD Ryzen 7 5800X',
            'memory' => '16 GB RAM',
            'graphics' => 'NVIDIA RTX 3070 / AMD RX 6800',
            'storage' => '60 GB SSD 可用空间',
            'directx' => 'Version 12'
        ]
    ]
];
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo htmlspecialchars($game['title']); ?> | 游戏详情</title>
    <!-- Tailwind CSS -->
    <script src="https://cdn.tailwindcss.com"></script>
    <!-- Font Awesome -->
    <link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
    
    <!-- Tailwind 配置 -->
    <script>
        tailwind.config = {
            theme: {
                extend: <?php echo json_encode($themeConfig ?? []);?>
            }
        }
    </script>
    <!-- 自定义工具类 -->
    <style type="text/tailwindcss">
        @layer utilities {
            .content-auto {
                content-visibility: auto;
            }
            .transition-custom {
                transition: all 0.3s ease;
            }
            <?php if (!empty($pageConfig['custom_utilities'])): ?>
                <?php echo $pageConfig['custom_utilities']; ?>
            <?php endif; ?>
        }
    </style>
</head>
<body class="bg-gray-50 font-sans text-gray-800">
    <?php
    // 引入头部导航
    if (is_callable('renderComponent')) {
        call_user_func('renderComponent', 'header');
    }
    ?>
    <!-- 主内容 -->
    <main class="">
        <!-- 游戏封面区 -->
        <section class="relative h-[60vh] min-h-[400px] flex items-center overflow-hidden">
            <div class="absolute inset-0 z-0">
                <div class="absolute inset-0 bg-gradient-to-t from-black via-black/70 to-transparent z-10"></div>
                <img 
                    src="<?php echo htmlspecialchars($game['cover_image']); ?>"
                    alt="<?php echo htmlspecialchars($game['title']); ?> 封面"
                    class="w-full h-full object-cover"
                >
            </div>
            <div class="container mx-auto px-4 sm:px-6 lg:px-8 relative z-20">
                <div class="flex flex-wrap gap-3 mb-4">
                    <span class="inline-block px-3 py-1 bg-primary/90 text-white text-sm font-medium rounded-full backdrop-blur-sm">
                        <?php echo htmlspecialchars($game['category']); ?>
                    </span>
                    <?php foreach (array_slice($game['tags'], 0, 2) as $tag): ?>
                        <span class="inline-block px-3 py-1 bg-white/20 text-white text-sm font-medium rounded-full backdrop-blur-sm">
                            <?php echo htmlspecialchars($tag); ?>
                        </span>
                    <?php endforeach; ?>
                </div>
                <h1 class="text-3xl md:text-5xl font-bold text-white mb-2 text-shadow">
                    <?php echo htmlspecialchars($game['title']); ?>
                </h1>
                <p class="text-xl text-gray-200 mb-6 max-w-2xl">
                    <?php echo htmlspecialchars($game['subtitle']); ?>
                </p>
                <div class="flex flex-wrap gap-4 items-center mb-6">
                    <div class="flex items-center">
                        <div class="star-rating flex mr-2">
                            <?php for ($i = 1; $i <= 5; $i++): ?>
                                <i class="fa fa-star <?php echo $i <= $game['rating'] ? 'text-yellow-400' : 'text-gray-400'; ?>"></i>
                            <?php endfor; ?>
                        </div>
                        <span class="text-white font-medium"><?php echo htmlspecialchars($game['rating']); ?></span>
                        <span class="text-gray-300 ml-1">(<?php echo htmlspecialchars($game['rating_count']); ?>)</span>
                    </div>
                    <span class="text-gray-300">|</span>
                    <span class="text-white">
                        <i class="fa fa-calendar mr-1"></i>
                        <?php echo htmlspecialchars($game['release_date']); ?>
                    </span>
                </div>
                <div class="flex flex-wrap gap-4">
                    <a href="#" class="px-8 py-3 btn-gradient text-white font-medium rounded-lg transition-all duration-300 flex items-center shadow-lg shadow-primary/20">
                        <i class="fa fa-shopping-cart mr-2"></i>
                        立即购买 <?php echo htmlspecialchars($game['discounted_price']); ?>
                    </a>
                    <a href="#" class="px-6 py-3 bg-white/20 backdrop-blur-sm text-white font-medium rounded-lg transition-all duration-300 hover:bg-white/30 flex items-center">
                        <i class="fa fa-plus mr-2"></i>
                        加入愿望单
                    </a>
                    <a href="#" class="px-6 py-3 bg-white/20 backdrop-blur-sm text-white font-medium rounded-lg transition-all duration-300 hover:bg-white/30 flex items-center">
                        <i class="fa fa-play-circle mr-2"></i>
                        观看预告片
                    </a>
                </div>
            </div>
        </section>

        <!-- 游戏介绍区 -->
        <section class="py-16 bg-white">
            <div class="container mx-auto px-4 sm:px-6 lg:px-8">
                <div class="grid grid-cols-1 lg:grid-cols-3 gap-12">
                        <!-- 左侧信息 -->
                        <div class="lg:col-span-2">
                            <div class="mb-12">
                                <h2 class="text-3xl font-bold mb-6 text-dark">游戏介绍</h2>
                                <p class="text-gray-700 text-lg leading-relaxed mb-6">
                                    <?php echo htmlspecialchars($game['description']); ?>
                                </p>
                                <p class="text-gray-700 text-lg leading-relaxed">
                                    <?php echo htmlspecialchars($game['storyline']); ?>
                                </p>
                            </div>
                            
                            <!-- 游戏特性 -->
                            <div class="mb-12">
                                <h2 class="text-3xl font-bold mb-6 text-dark">游戏特性</h2>
                                <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                                    <?php foreach ($game['features'] as $index => $feature): ?>
                                        <div class="flex items-start">
                                            <div class="w-10 h-10 rounded-full bg-primary/10 flex items-center justify-center text-primary mr-4 mt-0.5 flex-shrink-0">
                                                <i class="fa fa-rocket"></i>
                                            </div>
                                            <p class="text-gray-700"><?php echo htmlspecialchars($feature); ?></p>
                                        </div>
                                    <?php endforeach; ?>
                                </div>
                            </div>
                            
                            <!-- 游戏玩法 -->
                            <div class="mb-12">
                                <h2 class="text-3xl font-bold mb-6 text-dark">游戏玩法</h2>
                                <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                                    <?php foreach ($game['gameplay'] as $gameplay): ?>
                                        <div class="flex items-center bg-gray-50 p-4 rounded-xl">
                                            <div class="w-12 h-12 rounded-full bg-accent/10 flex items-center justify-center text-accent mr-4 flex-shrink-0">
                                                <i class="fa fa-gamepad"></i>
                                            </div>
                                            <span class="text-gray-700 font-medium"><?php echo htmlspecialchars($gameplay); ?></span>
                                        </div>
                                    <?php endforeach; ?>
                                </div>
                            </div>
                            
                            <!-- 游戏截图 -->
                            <div>
                                <h2 class="text-3xl font-bold mb-6 text-dark">游戏截图</h2>
                                <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                                    <?php foreach ($game['screenshots'] as $screenshot): ?>
                                        <div class="rounded-xl overflow-hidden shadow-lg transform transition-all duration-500 screenshot-hover">
                                            <img 
                                                src="<?php echo htmlspecialchars($screenshot); ?>"
                                                alt="游戏截图"
                                                class="w-full h-auto"
                                            >
                                        </div>
                                    <?php endforeach; ?>
                                </div>
                            </div>
                        </div>
                        
                        <!-- 右侧侧边栏 -->
                        <div class="lg:col-span-1">
                            <!-- 购买卡片 -->
                            <div class="bg-white rounded-xl game-card-shadow p-6 mb-8 sticky top-24">
                                <div class="flex items-center justify-between mb-4">
                                    <div>
                                        <span class="text-2xl font-bold text-dark">
                                            <?php echo htmlspecialchars($game['discounted_price']); ?>
                                        </span>
                                        <span class="ml-2 text-gray-500 line-through">
                                            <?php echo htmlspecialchars($game['price']); ?>
                                        </span>
                                    </div>
                                    <?php if (!empty($game['discount'])): ?>
                                        <span class="px-3 py-1 bg-secondary text-white text-sm font-medium rounded-full">
                                            省 <?php echo htmlspecialchars($game['discount']); ?>
                                        </span>
                                    <?php endif; ?>
                                </div>
                                <div class="space-y-4">
                                    <a href="#" class="block w-full py-3 btn-gradient text-center text-white font-medium rounded-lg transition-all duration-300 shadow-lg shadow-primary/20">
                                        立即购买
                                    </a>
                                    <a href="#" class="block w-full py-3 border border-primary text-primary font-medium rounded-lg transition-all duration-300 hover:bg-primary/5 text-center">
                                        加入愿望单
                                    </a>
                                </div>
                                
                                <!-- 开发商信息 -->
                                <div class="mt-6 pt-6 border-t border-gray-100">
                                    <div class="flex justify-between items-start mb-2">
                                        <span class="text-gray-500">开发商</span>
                                        <span class="font-medium text-dark"><?php echo htmlspecialchars($game['developer']); ?></span>
                                    </div>
                                    <div class="flex justify-between items-start mb-2">
                                        <span class="text-gray-500">发行商</span>
                                        <span class="font-medium text-dark"><?php echo htmlspecialchars($game['publisher']); ?></span>
                                    </div>
                                    <div class="flex justify-between items-start mb-2">
                                        <span class="text-gray-500">发行日期</span>
                                        <span class="font-medium text-dark"><?php echo htmlspecialchars($game['release_date']); ?></span>
                                    </div>
                                    <div class="flex flex-col gap-2 mt-2">
                                        <span class="text-gray-500">平台</span>
                                        <div class="flex flex-wrap gap-2">
                                            <?php foreach ($game['platforms'] as $platform): ?>
                                                <span class="px-3 py-1 bg-gray-100 text-gray-700 text-sm font-medium rounded-full">
                                                    <?php echo htmlspecialchars($platform); ?>
                                                </span>
                                            <?php endforeach; ?>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
             </div>
        </section>

        <!-- 系统要求 -->
        <section class="py-16 bg-gray-50 bg-game-pattern">
            <div class="container mx-auto px-4 sm:px-6 lg:px-8">
                <h2 class="text-3xl font-bold mb-10 text-center text-dark">系统要求</h2>
                <div class="grid grid-cols-1 md:grid-cols-2 gap-8">
                    <!-- 最低配置 -->
                    <div class="bg-white rounded-xl game-card-shadow p-8">
                        <div class="flex items-center mb-6">
                            <div class="w-12 h-12 rounded-full bg-gray-100 flex items-center justify-center text-gray-600 mr-4">
                                <i class="fa fa-microchip text-xl"></i>
                            </div>
                            <h3 class="text-xl font-bold">最低配置</h3>
                        </div>
                        <ul class="space-y-4">
                            <?php foreach ($game['system_requirements']['minimum'] as $key => $value): ?>
                                <li class="flex justify-between">
                                    <span class="text-gray-500 capitalize">
                                        <?php echo str_replace('_', ' ', $key); ?>
                                    </span>
                                    <span class="font-medium text-dark"><?php echo htmlspecialchars($value); ?></span>
                                </li>
                            <?php endforeach; ?>
                        </ul>
                    </div>
                    
                    <!-- 推荐配置 -->
                    <div class="bg-white rounded-xl game-card-shadow p-8">
                        <div class="flex items-center mb-6">
                            <div class="w-12 h-12 rounded-full bg-primary/10 flex items-center justify-center text-primary mr-4">
                                <i class="fa fa-rocket text-xl"></i>
                            </div>
                            <h3 class="text-xl font-bold">推荐配置</h3>
                        </div>
                        <ul class="space-y-4">
                            <?php foreach ($game['system_requirements']['recommended'] as $key => $value): ?>
                                <li class="flex justify-between">
                                    <span class="text-gray-500 capitalize">
                                        <?php echo str_replace('_', ' ', $key); ?>
                                    </span>
                                    <span class="font-medium text-dark"><?php echo htmlspecialchars($value); ?></span>
                                </li>
                            <?php endforeach; ?>
                        </ul>
                    </div>
                </div>
            
            </div>
        </section>

        
        
        <!-- 引入页面依赖的碎片 -->
        <?php if (!empty($pageConfig['dependencies'])): ?>
            <?php foreach ($pageConfig['dependencies'] as $fragment): ?>
                <?php
                // 使用渲染组件函数
                if (is_callable('renderComponent')) {
                    call_user_func('renderComponent', $fragment);
                }
                ?>
            <?php endforeach; ?>
        <?php endif; ?>
    </main>
    <?php
    // 引入头部导航
    if (is_callable('renderComponent')) {
        call_user_func('renderComponent', 'footer');
    }
    // 引入头部导航
    if (is_callable('renderComponent')) {
        call_user_func('renderComponent', 'scripts');
    }
    ?>
</body>
</html>